package com.kapcb.mvc.validator;

import cn.hutool.core.util.PhoneUtil;
import com.kapcb.mvc.annotation.Mobile;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * <a>Title: MobileValidator </a>
 * <a>Author: kapcb <a>
 * <a>Description: MobileValidator <a>
 *
 * @author Kpacb
 * @version 1.0
 * @date 2024/5/1 15:01
 * @since 1.0
 */
public class MobileValidator implements ConstraintValidator<Mobile, String> {

    @Override
    public boolean isValid(String mobile, ConstraintValidatorContext constraintValidatorContext) {
        // 校验手机
        return PhoneUtil.isMobile(mobile) || PhoneUtil.isMobileHk(mobile) || PhoneUtil.isMobileTw(mobile) || PhoneUtil.isMobileMo(mobile);
    }

}
